package model;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;

/**
 * @author soreas + morarg Entity implementation class for Entity: Membership
 * 
 */
@Entity
@SequenceGenerator(name = "seq", initialValue = 1, allocationSize = 100)
public class Membership implements Serializable {

	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq")
	@Id
	@Column(name = "ID")
	// @GeneratedValue(strategy = GenerationType.AUTO)
	private Integer id;

	private User user;

	private Folder folder;

	@Column(nullable = false)
	private Integer supervisor;
	private static final long serialVersionUID = 1L;

	public Membership() {
		super();
	}

	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public User getUser() {
		return this.user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public Folder getFolder() {
		return this.folder;
	}

	public void setFolder(Folder folder) {
		this.folder = folder;
	}

	public Integer getSupervisor() {
		return this.supervisor;
	}

	public void setSupervisor(Integer supervisor) {
		this.supervisor = supervisor;
	}

	@Override
	public String toString() {
		return "Membership [id=" + id + ", user=" + user + ", folder=" + folder
				+ ", supervisor=" + supervisor + "]";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Membership other = (Membership) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}

}
